package filter;

public class MyFilter {
}

        import javax.servlet.*;
        import javax.servlet.annotation.*;
        import java.io.IOException;
        import java.io.PrintWriter;

@WebFilter(filterName = "MyFilter",urlPatterns = "/MyServlet")
public class MyFilter implements Filter {
    public void init(FilterConfig config) throws ServletException {
    }

    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.write("Hello MyFilter--------");
    }
}
